Document

interface Document : Node

An HTML DOM document.

Properties

Link copied to clipboard

Returns the document HTML element that usually represents HTML tag, if any.

Link copied to clipboard

Returns the currently focused element in the document, if any.

Link copied to clipboard

Returns the next node in the document tree, if any.

Link copied to clipboard

Returns the parent of this node, if any.

Link copied to clipboard

Returns the previous node in the document tree, if any.

Link copied to clipboard

Returns XPathExpression that represents path to this Node, or an empty expression if it is not available.

Functions

Link copied to clipboard
abstract fun addEventListener(eventType: EventType, listener: Observer<Event>, useCapture: Boolean)
Adds the given listener to the event target.
Link copied to clipboard
abstract fun appendChild(childNode: Node): Boolean
Adds the given node as a child of the current node to the end of its children list.
Link copied to clipboard
abstract fun baseUri(): String
Returns a string that represents the <base> element's href attribute if one is present.
Link copied to clipboard
abstract fun children(): List<Node>
Returns an immutable list of all children of this node.
Link copied to clipboard
abstract fun click()
Simulates a click on the node.
Link copied to clipboard
abstract fun close()
Closes this node.
Link copied to clipboard
abstract fun compareDocumentPosition(otherNode: Node): Set<DocumentPosition>
Compares position of the current node against another node in a DOM tree.
Link copied to clipboard
abstract fun createCustomEvent(eventType: EventType, params: CustomEventParams): CustomEvent
Creates and returns a new CustomEvent object with the given eventType and params.
Link copied to clipboard
abstract fun createElement(tagName: String): Element
Creates and returns a new DOM element with the given tagName.
Link copied to clipboard
abstract fun createEvent(eventType: EventType, params: EventParams): Event
Creates and returns a new Event object with the given eventType and params.
Link copied to clipboard
Creates a new KeyEvent instance with the KEY_DOWN event type and the given params.
Link copied to clipboard
Creates a new KeyEvent instance with the KEY_PRESS event type and the given params.
Link copied to clipboard
Creates a new KeyEvent instance with the KEY_UP event type and the given params.
Link copied to clipboard
abstract fun createMouseEvent(eventType: EventType, params: MouseEventParams): MouseEvent
Creates and returns a new MouseEvent object with the given eventType and params.
Link copied to clipboard
abstract fun createTextNode(): Node
Creates and returns a Node object representing a new text node with an empty node value.
abstract fun createTextNode(text: String): Node
Creates and returns a Node object representing a new text node initialized with the given text value.
Link copied to clipboard
abstract fun createWheelEvent(eventType: EventType, params: WheelEventParams): WheelEvent
Creates and returns a new WheelEvent object with the given eventType and params.
Link copied to clipboard
abstract fun dispatch(event: Event): Boolean
Dispatches the given event at the current event target.
Link copied to clipboard
abstract fun document(): Document
Returns the Document instance of this node.
Link copied to clipboard
Returns an Optional that contains the document HTML element that usually represents HTML tag, otherwise an empty Optional if the document element is not available.
Link copied to clipboard
abstract fun evaluate(expression: String): XPathResult
Evaluates the given XPath expression for the node and returns the XPathResult of the ANY type.
abstract fun evaluate(expression: String, type: XPathResultType): XPathResult
Evaluates the given XPath expression for the node and returns the XPathResult object of the given type.
Link copied to clipboard

Evaluates the given expression for the node and returns XPathResult of the XPathResultType.ANY type.

fun Node.evaluate(expression: XPathExpression, type: XPathResultType): XPathResult
fun Node.evaluate(expression: XPathExpression, type: XPathResultType): XPathResult

Evaluates the given expression for the node and returns XPathResult of the given type.

Link copied to clipboard
abstract fun eventListeners(eventType: EventType, useCapture: Boolean): List<Observer<Event>>
Returns the immutable list of event listeners that listen events of the given eventType in a phase that corresponds the given useCapture.
Link copied to clipboard

Returns the first Element found in the current search context by the given className, if any.

Link copied to clipboard

Returns the first Element found in the current search context by the given cssSelector, if any.

Link copied to clipboard

Returns the first Element found in the current search context by the given id, if any.

Link copied to clipboard

Returns the first Element found in the current search context by the given name, if any.

Link copied to clipboard

Returns the first Element found in the current search context by the given tagName, if any.

Link copied to clipboard
abstract fun findElementByClassName(className: String): Optional<Element>
Returns the first Element object found in the current search context by the given className.
Link copied to clipboard
abstract fun findElementByCssSelector(cssSelector: String): Optional<Element>
Returns the first Element object found in the current search context by the given cssSelector.
Link copied to clipboard
Returns the first Element object found in the current search context by the given id.
Link copied to clipboard
Returns the first Element object found in the current search context by the given name.
Link copied to clipboard
abstract fun findElementByTagName(tagName: String): Optional<Element>
Returns the first Element object found in the current search context by the given tagName.
Link copied to clipboard
abstract fun findElementsByClassName(className: String): List<Element>
Returns an immutable list of the Element objects found in the current search context by the given className.
Link copied to clipboard
abstract fun findElementsByCssSelector(cssSelector: String): List<Element>
Returns an immutable list of the Element objects found in the current search context by the given cssSelector.
Link copied to clipboard
abstract fun findElementsById(id: String): List<Element>
Returns an immutable list of the Element objects found in the current search context by the given id.
Link copied to clipboard
abstract fun findElementsByName(name: String): List<Element>
Returns an immutable list of the Element objects found in the current search context by the given name.
Link copied to clipboard
abstract fun findElementsByTagName(tagName: String): List<Element>
Returns an immutable list of the Element objects found in the current search context by the given tagName.
Link copied to clipboard
Returns an Optional that contains the currently focused element in the document, otherwise an empty Optional if there is no focused element in this document.
Link copied to clipboard
abstract fun frame(): Frame
Returns the Frame instance of this document.
Link copied to clipboard

Returns the first Element found in the current search context by the given className.

Link copied to clipboard

Returns the first Element found in the current search context by the given cssSelector.

Link copied to clipboard

Returns the first Element found in the current search context by the given id.

Link copied to clipboard

Returns the first Element found in the current search context by the given name.

Link copied to clipboard

Returns the first Element found in the current search context by the given tagName.

Link copied to clipboard
abstract fun insertChild(node: Node, beforeNode: Node): Boolean
Inserts the given node before the given beforeNode as a child of the current node.
Link copied to clipboard
abstract fun nextSibling(): Optional<Node>
Returns an Optional that contains the next node in the document tree if such a node exists, otherwise returns an empty Optional.
Link copied to clipboard
abstract fun nodeName(): String
Returns a string that represents the node name in the UTF8 format.
Link copied to clipboard
abstract fun nodeValue(): String
Returns a string that represents the node value.
abstract fun nodeValue(value: String)
Updates the node value with the given new value.
Link copied to clipboard
abstract fun parent(): Optional<Node>
Returns an Optional that contains the parent of this node.
Link copied to clipboard
abstract fun previousSibling(): Optional<Node>
Returns an Optional that contains the previous node in the document tree if such a node exists, otherwise returns an empty Optional.
Link copied to clipboard
abstract fun removeChild(childNode: Node): Boolean
Removes the given childNode of the current node from the DOM.
Link copied to clipboard
abstract fun removeEventListener(eventType: EventType, listener: Observer<Event>, useCapture: Boolean)
Removes the given listener from the event target.
Link copied to clipboard
abstract fun replaceChild(newNode: Node, oldNode: Node): Boolean
Replaces the given child oldNode of the current node with the given newNode.
Link copied to clipboard
abstract fun textContent(): String
Returns the text content of the current node and its descendants.
abstract fun textContent(textContent: String)
Removes all the current node children and replaces them with a single text node with the given textContent.
Link copied to clipboard
abstract fun type(): NodeType
Returns the node type.
Link copied to clipboard
abstract fun xPath(): String
Returns a string that represents XPath to the current Node or an empty string if it is not available.